<template>
    <!-- <view class="datePicker" ref="datePicker" catchtouchmove="true"> -->
    <view class="datePicker" ref="datePicker">
        <uni-popup ref="popup" type="bottom">
            <view class="popupBox">
                <view class="dtitle">
					 <view class="close" @click="cancelFunction();">取消</view>
                    <view class="name">{{title}}</view>
                    <view class="confirm" @click="confirmFunction();">确定</view>
                </view>
                <picker-view 
                    @change="onChange($event)" 
                    class="picker-view"
                    @pickstart="pickStart($event)"
                    @pickend="pickEnd()"
                    :value="dateValue"
                >
                    <picker-view-column v-for="(item,index) in data" :key="index">
                        <view class="item" v-for="(item1,index1) in item.data" :key="index1">{{item1}}{{item.$name}}</view>
                    </picker-view-column>
                </picker-view>
                
            </view>
        </uni-popup>
    </view>
</template>

<script>
    // import uniPopup from '@/components/uni-popup/uni-popup.vue';
    export default {
        // components:{
        //     uniPopup
        // },
        data () {
            return {
                data:[],                    //初始化时间维度    
                changeObj:[],                //初始化选中的数据
                isDataFinish:true,            //初始化数据是否选择完毕
                normalDate:"",                //初始化默认选择的时间
                dateValue:[],                //初始化拨盘选择默认值
                tempChangeObj:[],            //初始化滚动选中
            }
        },
        props:{
            // title名称，类型 String 默认 ""
            "title":{
                type:String,
                default:"请选择时间"
            },
            // 拨盘类型，类型 String 默认 "yy-mm-dd"
            "type":{
                type:String,
                default:"yy-mm-dd"
            },
            // 最小选择时间
            "minDate":{
                type:String,
                default:"2000-01-01 00:00:00"
            },
            // 最小选择时间
            "maxDate":{
                type:String,
                default:"3000-01-01 00:00:00"
            },
            // 初始默认时间
            "initDate":{
                type:String,
                default:""
            },
            // 确认按钮名称 类型 String 默认 "确认"
            'confirmButtonText':{
                type:String,
                default:'确认'
            },
            // 确认方法名-兼容微信小程序无法获取父组件是否传递过来参数的补丁
            'mpWeixinConfirm':{
                type:String
            },
            // 确认方法名-兼容微信小程序无法获取父组件是否传递过来参数的补丁
            'mpWeixinCancel':{
                type:String
            }
        },
        methods: {
            // open 开启弹窗方法
            open(){
                this.data=[];
                // 重置默认选择的日期时间
                if(!this.initDate||new Date(this.initDate).getTime()<new Date(this.minDate).getTime()||new Date(this.initDate).getTime()>new Date(this.maxDate).getTime()){
                    this.normalDate = this.minDate;
                }else{
                    this.normalDate = this.initDate;
                }
                // 获取类型
                switch(this.type){
                    case "yy":
                        // 追加年数据
                        var year = {};
                        year.name = "year";
                        year.$name = "年"
                        year.data = [];
                        var yearInterval = this.maxDate.split("-")[0] - this.minDate.split("-")[0];
                        for(let a=0;a<=yearInterval;a++){
                            year.data.push(parseInt(this.minDate.split("-")[0])+a);
                            if(this.normalDate.split("-")[0]==(parseInt(this.minDate.split("-")[0])+a)){
                                this.dateValue.push(a)
                            }
                        }
                        this.tempChangeObj = this.dateValue;
                        this.data.push(year);
                        break;
                    case "yy-mm":
                        //追加年数据
                        var year = {};
                        year.name = "year";
                        year.$name = "年"
                        year.data = [];
                        var yearInterval = this.maxDate.split("-")[0] - this.minDate.split("-")[0];
                        for(let a=0;a<=yearInterval;a++){
                            year.data.push(parseInt(this.minDate.split("-")[0])+a);
                            if(this.normalDate.split("-")[0]==(parseInt(this.minDate.split("-")[0])+a)){
                                this.dateValue.push(a)
                            }
                        }
                        this.data.push(year);
                        // 追加月数据
                        var month = {};
                        month.name = "month";
                        month.$name = "月";
                        month.data = [];
                        // 判断年份如果在同一年
                        var monthInterval = 0;
                        if(yearInterval>0){
                            monthInterval = 12;
                            for(let b=1;b<=monthInterval;b++){
                                month.data.push(b<10?("0"+b):b);
                                if(this.normalDate.split(" ")[0].split("-")[1]==(b<10?("0"+b):b)){
                                    this.dateValue.push(b-1)
                                }
                            }
                        }else{
                            monthInterval = this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1];
                            for(let b=0;b<=monthInterval;b++){
                                month.data.push((parseInt(this.minDate.split(" ")[0].split("-")[1])+b)<10?("0"+(parseInt(this.minDate.split(" ")[0].split("-")[1])+b)):(parseInt(this.minDate.split(" ")[0].split("-")[1])+b));
                                if(parseInt(this.normalDate.split(" ")[0].split("-")[1])==parseInt(this.minDate.split(" ")[0].split("-")[1])+b){
                                    this.dateValue.push(b)
                                }
                            }
                        }
                        this.tempChangeObj = this.dateValue;
                        this.data.push(month);
                        break;
                    case "yy-mm-dd":
                        //追加年数据
                        var year = {};
                        year.name = "year";
                        year.$name = "年"
                        year.data = [];
                        var yearInterval = this.maxDate.split("-")[0] - this.minDate.split("-")[0];
                        for(let a=0;a<=yearInterval;a++){
                            year.data.push(parseInt(this.minDate.split("-")[0])+a);
                            if(this.normalDate.split("-")[0]==(parseInt(this.minDate.split("-")[0])+a)){
                                this.dateValue.push(a)
                            }
                        }
                        this.data.push(year);
                        // 追加月数据
                        var month = {};
                        month.name = "month";
                        month.$name = "月";
                        month.data = [];
                        // 判断年份如果在同一年
                        var monthInterval = 0;
                        if(yearInterval>0){
                            monthInterval = 12;
                            for(let b=1;b<=monthInterval;b++){
                                month.data.push(b<10?("0"+b):b);
                                if(this.normalDate.split(" ")[0].split("-")[1]==(b<10?("0"+b):b)){
                                    this.dateValue.push(b-1)
                                }
                            }
                        }else{
                            monthInterval = this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1];
                            for(let b=0;b<=monthInterval;b++){
                                month.data.push((parseInt(this.minDate.split(" ")[0].split("-")[1])+b)<10?("0"+(parseInt(this.minDate.split(" ")[0].split("-")[1])+b)):(parseInt(this.minDate.split(" ")[0].split("-")[1])+b));
                                if(parseInt(this.normalDate.split(" ")[0].split("-")[1])==parseInt(this.minDate.split(" ")[0].split("-")[1])+b){
                                    this.dateValue.push(b)
                                }
                            }
                        }
                        this.data.push(month);
                        // 追加日数据
                        var day = {};
                        day.name = "day";
                        day.$name = "日";
                        day.data = [];
                        // 判断年月是否在同一年同一月
                        var dayInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)){
                            dayInterval = this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2];
                            for(let c=0;c<=dayInterval;c++){
                                day.data.push((parseInt(this.minDate.split(" ")[0].split("-")[2])+c)<10?("0"+(parseInt(this.minDate.split(" ")[0].split("-")[2])+c)):(parseInt(this.minDate.split(" ")[0].split("-")[2])+c));
                                if(parseInt(this.normalDate.split(" ")[0].split("-")[2])==parseInt(this.minDate.split(" ")[0].split("-")[2])+c){
                                    this.dateValue.push(c)
                                }
                            }
                        }else{
                            var tempMonth = this.normalDate.split(" ")[0].split("-")[1];
                            // 判断是否为2月
                            if(tempMonth==2){
                                // 判断当前选择，是否闰年
                                if(this.normalDate.split(" ")[0].split("-")[0] % 4 == 0 && !(this.normalDate.split(" ")[0].split("-")[0] % 100 == 0) || this.normalDate.split(" ")[0].split("-")[0] % 400 == 0) {
                                    dayInterval = 29;
                                }else{
                                    dayInterval = 28;
                                }
                            }else if(tempMonth==1||tempMonth==3||tempMonth==5||tempMonth==7||tempMonth==8||tempMonth==10||tempMonth==12){
                                dayInterval = 31;
                            }else{
                                dayInterval = 30;
                            }
                            for(let c=1;c<=dayInterval;c++){
                                day.data.push(c<10?("0"+c):c);
                                if(this.normalDate.split(" ")[0].split("-")[2]==(c<10?("0"+c):c)){
                                    this.dateValue.push(c-1)
                                }
                            }
                        }
                        this.tempChangeObj = this.dateValue;
                        this.data.push(day);
                        break;
                    case "yy-mm-dd hh":
                        //追加年数据
                        var year = {};
                        year.name = "year";
                        year.$name = "年"
                        year.data = [];
                        var yearInterval = this.maxDate.split("-")[0] - this.minDate.split("-")[0];
                        for(let a=0;a<=yearInterval;a++){
                            year.data.push(parseInt(this.minDate.split("-")[0])+a);
                            if(this.normalDate.split("-")[0]==(parseInt(this.minDate.split("-")[0])+a)){
                                this.dateValue.push(a)
                            }
                        }
                        this.data.push(year);
                        // 追加月数据
                        var month = {};
                        month.name = "month";
                        month.$name = "月";
                        month.data = [];
                        // 判断年份如果在同一年
                        var monthInterval = 0;
                        if(yearInterval>0){
                            monthInterval = 12;
                            for(let b=1;b<=monthInterval;b++){
                                month.data.push(b<10?("0"+b):b);
                                if(this.normalDate.split(" ")[0].split("-")[1]==(b<10?("0"+b):b)){
                                    this.dateValue.push(b-1)
                                }
                            }
                        }else{
                            monthInterval = this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1];
                            for(let b=0;b<=monthInterval;b++){
                                month.data.push((parseInt(this.minDate.split(" ")[0].split("-")[1])+b)<10?("0"+(parseInt(this.minDate.split(" ")[0].split("-")[1])+b)):(parseInt(this.minDate.split(" ")[0].split("-")[1])+b));
                                if(parseInt(this.normalDate.split(" ")[0].split("-")[1])==parseInt(this.minDate.split(" ")[0].split("-")[1])+b){
                                    this.dateValue.push(b)
                                }
                            }
                        }
                        this.data.push(month);
                        // 追加日数据
                        var day = {};
                        day.name = "day";
                        day.$name = "日";
                        day.data = [];
                        // 判断年月是否在同一年同一月
                        var dayInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)){
                            dayInterval = this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2];
                            for(let c=0;c<=dayInterval;c++){
                                day.data.push((parseInt(this.minDate.split(" ")[0].split("-")[2])+c)<10?("0"+(parseInt(this.minDate.split(" ")[0].split("-")[2])+c)):(parseInt(this.minDate.split(" ")[0].split("-")[2])+c));
                                if(parseInt(this.normalDate.split(" ")[0].split("-")[2])==parseInt(this.minDate.split(" ")[0].split("-")[2])+c){
                                    this.dateValue.push(c)
                                }
                            }
                        }else{
                            var tempMonth = this.normalDate.split(" ")[0].split("-")[1];
                            // 判断是否为2月
                            if(tempMonth==2){
                                // 判断当前选择，是否闰年
                                if(this.normalDate.split(" ")[0].split("-")[0] % 4 == 0 && !(this.normalDate.split(" ")[0].split("-")[0] % 100 == 0) || this.normalDate.split(" ")[0].split("-")[0] % 400 == 0) {
                                    dayInterval = 29;
                                }else{
                                    dayInterval = 28;
                                }
                            }else if(tempMonth==1||tempMonth==3||tempMonth==5||tempMonth==7||tempMonth==8||tempMonth==10||tempMonth==12){
                                dayInterval = 31;
                            }else{
                                dayInterval = 30;
                            }
                            for(let c=1;c<=dayInterval;c++){
                                day.data.push(c<10?("0"+c):c);
                                if(this.normalDate.split(" ")[0].split("-")[2]==(c<10?("0"+c):c)){
                                    this.dateValue.push(c-1)
                                }
                            }
                        }
                        this.data.push(day);
                        // 追加时数据
                        var hour = {};
                        hour.name = "hour";
                        hour.$name = "时";
                        hour.data = [];
                        // 判断年月日是否一致
                        var hourInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)&&(this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2]==0)){
                            hourInterval = this.maxDate.split(" ")[1].split(":")[0] - this.minDate.split(" ")[1].split(":")[0];
                            for(let d=0;d<=hourInterval;d++){
                                hour.data.push((parseInt(this.minDate.split(" ")[1].split(":")[0])+d)<10?("0"+(parseInt(this.minDate.split(" ")[1].split(":")[0])+d)):(parseInt(this.minDate.split(" ")[1].split(":")[0])+d));
                                if(parseInt(this.normalDate.split(" ")[1].split(":")[0])==parseInt(this.minDate.split(" ")[1].split(":")[0])+d){
                                    this.dateValue.push(d)
                                }
                            }
                        }else{
                            hourInterval = 23
                            for(let d=0;d<=hourInterval;d++){
                                hour.data.push(d<10?("0"+d):d);
                                if(this.normalDate.split(" ")[1].split(":")[0]==(d<10?("0"+d):d)){
                                    this.dateValue.push(d)
                                }
                            }
                        }
                        this.tempChangeObj = this.dateValue;
                        this.data.push(hour);
                        break;
                    case "yy-mm-dd hh:mm":
                        //追加年数据
                        var year = {};
                        year.name = "year";
                        year.$name = "年"
                        year.data = [];
                        var yearInterval = this.maxDate.split("-")[0] - this.minDate.split("-")[0];
                        for(let a=0;a<=yearInterval;a++){
                            year.data.push(parseInt(this.minDate.split("-")[0])+a);
                            if(this.normalDate.split("-")[0]==(parseInt(this.minDate.split("-")[0])+a)){
                                this.dateValue.push(a)
                            }
                        }
                        this.data.push(year);
                        // 追加月数据
                        var month = {};
                        month.name = "month";
                        month.$name = "月";
                        month.data = [];
                        // 判断年份如果在同一年
                        var monthInterval = 0;
                        if(yearInterval>0){
                            monthInterval = 12;
                            for(let b=1;b<=monthInterval;b++){
                                month.data.push(b<10?("0"+b):b);
                                if(this.normalDate.split(" ")[0].split("-")[1]==(b<10?("0"+b):b)){
                                    this.dateValue.push(b-1)
                                }
                            }
                        }else{
                            monthInterval = this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1];
                            for(let b=0;b<=monthInterval;b++){
                                month.data.push((parseInt(this.minDate.split(" ")[0].split("-")[1])+b)<10?("0"+(parseInt(this.minDate.split(" ")[0].split("-")[1])+b)):(parseInt(this.minDate.split(" ")[0].split("-")[1])+b));
                                if(parseInt(this.normalDate.split(" ")[0].split("-")[1])==parseInt(this.minDate.split(" ")[0].split("-")[1])+b){
                                    this.dateValue.push(b)
                                }
                            }
                        }
                        this.data.push(month);
                        // 追加日数据
                        var day = {};
                        day.name = "day";
                        day.$name = "日";
                        day.data = [];
                        // 判断年月是否在同一年同一月
                        var dayInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)){
                            dayInterval = this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2];
                            for(let c=0;c<=dayInterval;c++){
                                day.data.push((parseInt(this.minDate.split(" ")[0].split("-")[2])+c)<10?("0"+(parseInt(this.minDate.split(" ")[0].split("-")[2])+c)):(parseInt(this.minDate.split(" ")[0].split("-")[2])+c));
                                if(parseInt(this.normalDate.split(" ")[0].split("-")[2])==parseInt(this.minDate.split(" ")[0].split("-")[2])+c){
                                    this.dateValue.push(c)
                                }
                            }
                        }else{
                            var tempMonth = this.normalDate.split(" ")[0].split("-")[1];
                            // 判断是否为2月
                            if(tempMonth==2){
                                // 判断当前选择，是否闰年
                                if(this.normalDate.split(" ")[0].split("-")[0] % 4 == 0 && !(this.normalDate.split(" ")[0].split("-")[0] % 100 == 0) || this.normalDate.split(" ")[0].split("-")[0] % 400 == 0) {
                                    dayInterval = 29;
                                }else{
                                    dayInterval = 28;
                                }
                            }else if(tempMonth==1||tempMonth==3||tempMonth==5||tempMonth==7||tempMonth==8||tempMonth==10||tempMonth==12){
                                dayInterval = 31;
                            }else{
                                dayInterval = 30;
                            }
                            for(let c=1;c<=dayInterval;c++){
                                day.data.push(c<10?("0"+c):c);
                                if(this.normalDate.split(" ")[0].split("-")[2]==(c<10?("0"+c):c)){
                                    this.dateValue.push(c-1)
                                }
                            }
                        }
                        this.data.push(day);
                        // 追加时数据
                        var hour = {};
                        hour.name = "hour";
                        hour.$name = "时";
                        hour.data = [];
                        // 判断年月日是否一致
                        var hourInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)&&(this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2]==0)){
                            hourInterval = this.maxDate.split(" ")[1].split(":")[0] - this.minDate.split(" ")[1].split(":")[0];
                            for(let d=0;d<=hourInterval;d++){
                                hour.data.push((parseInt(this.minDate.split(" ")[1].split(":")[0])+d)<10?("0"+(parseInt(this.minDate.split(" ")[1].split(":")[0])+d)):(parseInt(this.minDate.split(" ")[1].split(":")[0])+d));
                                if(parseInt(this.normalDate.split(" ")[1].split(":")[0])==parseInt(this.minDate.split(" ")[1].split(":")[0])+d){
                                    this.dateValue.push(d)
                                }
                            }
                        }else{
                            hourInterval = 23
                            for(let d=0;d<=hourInterval;d++){
                                hour.data.push(d<10?("0"+d):d);
                                if(this.normalDate.split(" ")[1].split(":")[0]==(d<10?("0"+d):d)){
                                    this.dateValue.push(d)
                                }
                            }
                        }
                        this.data.push(hour);
                        // 追加分数据
                        var minute = {};
                        minute.name = "minute";
                        minute.$name = "分";
                        minute.data = [];
                        // 判断年月日时是否一致
                        var minuteInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)&&(this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2]==0)&&(this.maxDate.split(" ")[1].split(":")[0] - this.minDate.split(" ")[1].split(":")[0]==0)){
                            minuteInterval = this.maxDate.split(" ")[1].split(":")[1] - this.minDate.split(" ")[1].split(":")[1];
                            for(let e=0;e<=minuteInterval;e++){
                                minute.data.push((parseInt(this.minDate.split(" ")[1].split(":")[1])+e)<10?("0"+(parseInt(this.minDate.split(" ")[1].split(":")[1])+e)):(parseInt(this.minDate.split(" ")[1].split(":")[1])+e));
                                if(parseInt(this.normalDate.split(" ")[1].split(":")[1])==parseInt(this.minDate.split(" ")[1].split(":")[1])+e){
                                    this.dateValue.push(e)
                                }
                            }
                        }else{
                            minuteInterval = 59
                            for(let e=0;e<=minuteInterval;e++){
                                minute.data.push(e<10?("0"+e):e);
                                if(this.normalDate.split(" ")[1].split(":")[1]==(e<10?("0"+e):e)){
                                    this.dateValue.push(e)
                                }
                            }
                        }
                        this.tempChangeObj = this.dateValue;
                        this.data.push(minute);
                        break;
                    case "yy-mm-dd hh:mm:ss":
                        //追加年数据
                        var year = {};
                        year.name = "year";
                        year.$name = "年"
                        year.data = [];
                        var yearInterval = this.maxDate.split("-")[0] - this.minDate.split("-")[0];
                        for(let a=0;a<=yearInterval;a++){
                            year.data.push(parseInt(this.minDate.split("-")[0])+a);
                            if(this.normalDate.split("-")[0]==(parseInt(this.minDate.split("-")[0])+a)){
                                this.dateValue.push(a)
                            }
                        }
                        this.data.push(year);
                        // 追加月数据
                        var month = {};
                        month.name = "month";
                        month.$name = "月";
                        month.data = [];
                        // 判断年份如果在同一年
                        var monthInterval = 0;
                        if(yearInterval>0){
                            monthInterval = 12;
                            for(let b=1;b<=monthInterval;b++){
                                month.data.push(b<10?("0"+b):b);
                                if(this.normalDate.split(" ")[0].split("-")[1]==(b<10?("0"+b):b)){
                                    this.dateValue.push(b-1)
                                }
                            }
                        }else{
                            monthInterval = this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1];
                            for(let b=0;b<=monthInterval;b++){
                                month.data.push((parseInt(this.minDate.split(" ")[0].split("-")[1])+b)<10?("0"+(parseInt(this.minDate.split(" ")[0].split("-")[1])+b)):(parseInt(this.minDate.split(" ")[0].split("-")[1])+b));
                                if(parseInt(this.normalDate.split(" ")[0].split("-")[1])==parseInt(this.minDate.split(" ")[0].split("-")[1])+b){
                                    this.dateValue.push(b)
                                }
                            }
                        }
                        this.data.push(month);
                        // 追加日数据
                        var day = {};
                        day.name = "day";
                        day.$name = "日";
                        day.data = [];
                        // 判断年月是否在同一年同一月
                        var dayInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)){
                            dayInterval = this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2];
                            for(let c=0;c<=dayInterval;c++){
                                day.data.push((parseInt(this.minDate.split(" ")[0].split("-")[2])+c)<10?("0"+(parseInt(this.minDate.split(" ")[0].split("-")[2])+c)):(parseInt(this.minDate.split(" ")[0].split("-")[2])+c));
                                if(parseInt(this.normalDate.split(" ")[0].split("-")[2])==parseInt(this.minDate.split(" ")[0].split("-")[2])+c){
                                    this.dateValue.push(c)
                                }
                            }
                        }else{
                            var tempMonth = this.normalDate.split(" ")[0].split("-")[1];
                            // 判断是否为2月
                            if(tempMonth==2){
                                // 判断当前选择，是否闰年
                                if(this.normalDate.split(" ")[0].split("-")[0] % 4 == 0 && !(this.normalDate.split(" ")[0].split("-")[0] % 100 == 0) || this.normalDate.split(" ")[0].split("-")[0] % 400 == 0) {
                                    dayInterval = 29;
                                }else{
                                    dayInterval = 28;
                                }
                            }else if(tempMonth==1||tempMonth==3||tempMonth==5||tempMonth==7||tempMonth==8||tempMonth==10||tempMonth==12){
                                dayInterval = 31;
                            }else{
                                dayInterval = 30;
                            }
                            for(let c=1;c<=dayInterval;c++){
                                day.data.push(c<10?("0"+c):c);
                                if(this.normalDate.split(" ")[0].split("-")[2]==(c<10?("0"+c):c)){
                                    this.dateValue.push(c-1)
                                }
                            }
                        }
                        this.data.push(day);
                        // 追加时数据
                        var hour = {};
                        hour.name = "hour";
                        hour.$name = "时";
                        hour.data = [];
                        // 判断年月日是否一致
                        var hourInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)&&(this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2]==0)){
                            hourInterval = this.maxDate.split(" ")[1].split(":")[0] - this.minDate.split(" ")[1].split(":")[0];
                            for(let d=0;d<=hourInterval;d++){
                                hour.data.push((parseInt(this.minDate.split(" ")[1].split(":")[0])+d)<10?("0"+(parseInt(this.minDate.split(" ")[1].split(":")[0])+d)):(parseInt(this.minDate.split(" ")[1].split(":")[0])+d));
                                if(parseInt(this.normalDate.split(" ")[1].split(":")[0])==parseInt(this.minDate.split(" ")[1].split(":")[0])+d){
                                    this.dateValue.push(d)
                                }
                            }
                        }else{
                            hourInterval = 23
                            for(let d=0;d<=hourInterval;d++){
                                hour.data.push(d<10?("0"+d):d);
                                if(this.normalDate.split(" ")[1].split(":")[0]==(d<10?("0"+d):d)){
                                    this.dateValue.push(d)
                                }
                            }
                        }
                        this.data.push(hour);
                        // 追加分数据
                        var minute = {};
                        minute.name = "minute";
                        minute.$name = "分";
                        minute.data = [];
                        // 判断年月日时是否一致
                        var minuteInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)&&(this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2]==0)&&(this.maxDate.split(" ")[1].split(":")[0] - this.minDate.split(" ")[1].split(":")[0]==0)){
                            minuteInterval = this.maxDate.split(" ")[1].split(":")[1] - this.minDate.split(" ")[1].split(":")[1];
                            for(let e=0;e<=minuteInterval;e++){
                                minute.data.push((parseInt(this.minDate.split(" ")[1].split(":")[1])+e)<10?("0"+(parseInt(this.minDate.split(" ")[1].split(":")[1])+e)):(parseInt(this.minDate.split(" ")[1].split(":")[1])+e));
                                if(parseInt(this.normalDate.split(" ")[1].split(":")[1])==parseInt(this.minDate.split(" ")[1].split(":")[1])+e){
                                    this.dateValue.push(e)
                                }
                            }
                        }else{
                            minuteInterval = 59
                            for(let e=0;e<=minuteInterval;e++){
                                minute.data.push(e<10?("0"+e):e);
                                if(this.normalDate.split(" ")[1].split(":")[1]==(e<10?("0"+e):e)){
                                    this.dateValue.push(e)
                                }
                            }
                        }
                        this.data.push(minute);
                        // 追加秒数据
                        var seconds = {};
                        seconds.name = "seconds";
                        seconds.$name = "秒";
                        seconds.data = [];
                        // 判断年月日时分是否一致
                        var secondsInterval = 0;
                        if(yearInterval==0&&(this.maxDate.split(" ")[0].split("-")[1] - this.minDate.split(" ")[0].split("-")[1]==0)&&(this.maxDate.split(" ")[0].split("-")[2] - this.minDate.split(" ")[0].split("-")[2]==0)&&(this.maxDate.split(" ")[1].split(":")[0] - this.minDate.split(" ")[1].split(":")[0]==0)&&(this.maxDate.split(" ")[1].split(":")[1] - this.minDate.split(" ")[1].split(":")[1]==0)){
                            secondsInterval = this.maxDate.split(" ")[1].split(":")[2] - this.minDate.split(" ")[1].split(":")[2];
                            for(let f=0;f<=secondsInterval;f++){
                                seconds.data.push((parseInt(this.minDate.split(" ")[1].split(":")[2])+f)<10?("0"+(parseInt(this.minDate.split(" ")[1].split(":")[2])+f)):(parseInt(this.minDate.split(" ")[1].split(":")[2])+f));
                                if(parseInt(this.normalDate.split(" ")[1].split(":")[2])==parseInt(this.minDate.split(" ")[1].split(":")[2])+f){
                                    this.dateValue.push(f)
                                }
                            }
                        }else{
                            secondsInterval = 59
                            for(let f=0;f<=secondsInterval;f++){
                                seconds.data.push(f<10?("0"+f):f);
                                if(this.normalDate.split(" ")[1].split(":")[2]==(f<10?("0"+f):f)){
                                    this.dateValue.push(f)
                                }
                            }
                        }
                        this.tempChangeObj = this.dateValue;
                        this.data.push(seconds);
                        break;
                }
                this.$refs.popup.open();
            },
            // close 关闭弹窗方法
            close(){
                this.$refs.popup.close();
            },
            // 拨盘选择
            onChange($event){
                // 此处请注意，微信小程序返回默认值，h5端不会返回
                var tempArray = $event.detail.value;
                
                // 判断年月是否改变
                if((tempArray[0]!=this.tempChangeObj[0]||tempArray[1]!=this.tempChangeObj[1])&&(this.data[0].data.length>1||this.data[1].data.length>1)){
                    var daySize = 0;
                    // 判断拨盘类型
                    if((this.type=="yy-mm-dd"||this.type=="yy-mm-dd hh"||this.type=="yy-mm-dd hh:mm"||this.type=="yy-mm-dd hh:mm:ss")&&parseInt(this.data[1].data[tempArray[1]])==2){
                        // 判断当前选择，是否闰年
                        if(parseInt(this.data[0].data[tempArray[0]]) % 4 == 0 && !(parseInt(this.data[0].data[tempArray[0]]) % 100 == 0) || parseInt(this.data[0].data[tempArray[0]]) % 400 == 0) {
                            daySize = 29;
                        }else{
                            daySize = 28;
                        }
                    }else if((this.type=="yy-mm-dd"||this.type=="yy-mm-dd hh"||this.type=="yy-mm-dd hh:mm"||this.type=="yy-mm-dd hh:mm:ss")&&(parseInt(this.data[1].data[tempArray[1]])==1||parseInt(this.data[1].data[tempArray[1]])==3||parseInt(this.data[1].data[tempArray[1]])==5||parseInt(this.data[1].data[tempArray[1]])==7||parseInt(this.data[1].data[tempArray[1]])==8||parseInt(this.data[1].data[tempArray[1]])==10||parseInt(this.data[1].data[tempArray[1]])==12)){
                        daySize = 31;
                    }else{
                        daySize = 30;
                    }
                    var temDay = [];
                    for(let x=1;x<=daySize;x++){
                        temDay.push(x<10?("0"+x):x)
                    }
                    this.data[2].data = temDay;
                }
                this.tempChangeObj=tempArray;
            },
            // 拨盘滚动开始
            pickStart($event){
                this.isDataFinish = false;
            },
            // 拨盘滚动结束
            pickEnd(){
                this.isDataFinish = true;
            },
            // 执行组件确认按钮绑定方法
            confirmFunction(){
                this.changeObj = [];
                // 组装输出数据
                for(let x=0;x<this.data.length;x++){
                    this.changeObj.push({
                        name:this.data[x].name,
                        $name:this.data[x].$name,
                        value:this.data[x].data[this.tempChangeObj[x]]
                    })
                }
                console.log(this.changeObj)
                // 判断是否正在滚动选择中
                if(!this.isDataFinish){
                    return false;
                }
                // 执行默认方法
                this.$refs.popup.close();
                // #ifdef MP-WEIXIN
                    // 判断父组件是否传递过来确认方法
                    // 次数区别处理，用以为 this.$listeners在微信小程序内获取为{}对象
                    if(this.$parent[this.mpWeixinConfirm]){
                        // 执行父组件传递过来的方法
                        this.$emit("confirm",this.changeObj);
                    }
                    return false;
                // #endif
                
                // 判断父组件是否传递过来确认方法
                if(this.$listeners['confirm']){
                    // 执行父组件传递过来的方法
                    this.$emit("confirm",this.changeObj);
                }
            },
            // 执行组件取消按钮绑定方法
            cancelFunction(){
                // #ifdef MP-WEIXIN
                    // 判断父组件是否传递过来取消方法
                    // 次数区别处理，用以为 this.$listeners在微信小程序内获取为{}对象
                    if(this.$parent[this.mpWeixinCancel]){
                        // 执行父组件传递过来的方法
                        this.$emit("cancel");
                    }else{
                        // 执行默认方法
                        this.$refs.popup.close();
                    }
                    return false;
                // #endif
                
                // 判断父组件是否传递过来取消方法
                if(this.$listeners['cancel']){
                    // 执行父组件传递过来的方法
                    this.$emit("cancel");
                }else{
                    // 执行默认方法
                    this.$refs.popup.close();
                }
            },
        }
    }
</script>

<style>
	.datePicker{
		background: #fff;
	}
    .popupBox .dtitle{
        position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 100rpx;
		font-size: 36rpx;
		padding: 0 30rpx;
		margin-bottom: 20rpx;
		border-bottom: 1px solid #e5e5e5;
		color: #888;
    }
	.popupBox .dtitle .name{color: #333;}
	.popupBox .dtitle .confirm{color: #007aff;}
     
    
    /* 拨盘公共样式 */
    .picker-view {
        /* width: 750rpx; */
        height: 500rpx;
    }
    .picker-view .item {
        height: 50px;
        display: block;
        line-height: 34px;
        // #ifdef H5
        line-height: 50px;
        // #endif
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    // #ifdef H5
    .uni-picker-view-indicator{
        height: 50px;
        line-height: 50px;
    }
    // #endif
    /deep/.indicatorClassA{
        height: 50px;
        line-height: 50px;
        border-top: 1rpx solid #FFA2A5;
        border-bottom: 1rpx solid #FFA2A5;
    }
    /deep/.indicatorClassB{
        height: 50px;
        line-height: 50px;
    }
	.popupBox{background: #fff!important;}
</style>important